/***
Chessboard
创建人：ZЁЯ¤　身高：168cm+；体重：57kg+；未婚（已有女友）；最爱的运动：睡觉；格言：路见不平，拔腿就跑。QQ：358315553。
创建时间：2012年12月05日 00:36:16
简要说明：这家伙很懒什么都没写。
用法举例：这家伙还是很懒什么都没写。
*/

package zero.stage3Ds.test{
	import flash.display.*;
	import flash.geom.*;
	import flash.utils.*;
	import zero.shaders.Float2;
	import zero.shaders.Pixel4;
	import zero.stage3Ds.*;
	
	/**
	 * 
	 * 棋盘
	 * 
	 */	
	public class Chessboard extends BaseEffect{
		
		public static const nameV:Vector.<String>=new <String>["alpha","dimension","color1","color2"];
		//ChessboardCode//为了编译进来
		public static const byteV:Vector.<int>=new <int>[
			0xa0,0x01,0x00,0x00,0x00,0xa1,0x01,
			
			//tex ft0.xyzw,v0.xyzw,fs0<2d>
			0x28,0x00,0x00,0x00, 0x00,0x00,0x0f,0x02, 0x00,0x00,0x00,0xe4,0x04,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x05,0x00,0x00,0x00,
			
			//mul ft1.xyzw,ft0.xyzw,fc0.xyzw
			0x03,0x00,0x00,0x00, 0x01,0x00,0x0f,0x02, 0x00,0x00,0x00,0xe4,0x02,0x00,0x00,0x00, 0x00,0x00,0x00,0xe4,0x01,0x00,0x00,0x00,
			
			//mul ft1.xyz,ft1.xyz,fc0.www
			0x03,0x00,0x00,0x00, 0x01,0x00,0x07,0x02, 0x01,0x00,0x00,0x24,0x02,0x00,0x00,0x00, 0x00,0x00,0x00,0x3f,0x01,0x00,0x00,0x00,
			
			//mul ft2.xyzw,ft0.xyzw,fc1.xyzw
			0x03,0x00,0x00,0x00, 0x02,0x00,0x0f,0x02, 0x00,0x00,0x00,0xe4,0x02,0x00,0x00,0x00, 0x01,0x00,0x00,0xe4,0x01,0x00,0x00,0x00,
			
			//mul ft2.xyz,ft2.xyz,fc1.www
			0x03,0x00,0x00,0x00, 0x02,0x00,0x07,0x02, 0x02,0x00,0x00,0x24,0x02,0x00,0x00,0x00, 0x01,0x00,0x00,0x3f,0x01,0x00,0x00,0x00,
			
			//div ft3.xy,v0.xy,fc2.xy
			0x04,0x00,0x00,0x00, 0x03,0x00,0x03,0x02, 0x00,0x00,0x00,0x04,0x04,0x00,0x00,0x00, 0x02,0x00,0x00,0x04,0x01,0x00,0x00,0x00,
			
			//frc ft4.xy,ft3.xy
			0x08,0x00,0x00,0x00, 0x04,0x00,0x03,0x02, 0x03,0x00,0x00,0x04,0x02,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
			
			//sub ft3.xy,ft3.xy,ft4.xy
			0x02,0x00,0x00,0x00, 0x03,0x00,0x03,0x02, 0x03,0x00,0x00,0x04,0x02,0x00,0x00,0x00, 0x04,0x00,0x00,0x04,0x02,0x00,0x00,0x00,
			
			//add ft3.x,ft3.x,ft3.y
			0x01,0x00,0x00,0x00, 0x03,0x00,0x01,0x02, 0x03,0x00,0x00,0x00,0x02,0x00,0x00,0x00, 0x03,0x00,0x00,0x01,0x02,0x00,0x00,0x00,
			
			//div ft3.x,ft3.x,fc2.z
			0x04,0x00,0x00,0x00, 0x03,0x00,0x01,0x02, 0x03,0x00,0x00,0x00,0x02,0x00,0x00,0x00, 0x02,0x00,0x00,0x02,0x01,0x00,0x00,0x00,
			
			//frc ft3.x,ft3.x
			0x08,0x00,0x00,0x00, 0x03,0x00,0x01,0x02, 0x03,0x00,0x00,0x00,0x02,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
			
			//seq ft3.x,ft3.x,fc2.w
			0x2c,0x00,0x00,0x00, 0x03,0x00,0x01,0x02, 0x03,0x00,0x00,0x00,0x02,0x00,0x00,0x00, 0x02,0x00,0x00,0x03,0x01,0x00,0x00,0x00,
			
			//mul ft1.xyzw,ft1.xyzw,ft3.xxxx
			0x03,0x00,0x00,0x00, 0x01,0x00,0x0f,0x02, 0x01,0x00,0x00,0xe4,0x02,0x00,0x00,0x00, 0x03,0x00,0x00,0x00,0x02,0x00,0x00,0x00,
			
			//sub ft3.x,fc3.x,ft3.x
			0x02,0x00,0x00,0x00, 0x03,0x00,0x01,0x02, 0x03,0x00,0x00,0x00,0x01,0x00,0x00,0x00, 0x03,0x00,0x00,0x00,0x02,0x00,0x00,0x00,
			
			//mul ft2.xyzw,ft2.xyzw,ft3.xxxx
			0x03,0x00,0x00,0x00, 0x02,0x00,0x0f,0x02, 0x02,0x00,0x00,0xe4,0x02,0x00,0x00,0x00, 0x03,0x00,0x00,0x00,0x02,0x00,0x00,0x00,
			
			//add ft0.xyzw,ft1.xyzw,ft2.xyzw
			0x01,0x00,0x00,0x00, 0x00,0x00,0x0f,0x02, 0x01,0x00,0x00,0xe4,0x02,0x00,0x00,0x00, 0x02,0x00,0x00,0xe4,0x02,0x00,0x00,0x00,
			
			//mul ft0.xyzw,ft0.xyzw,fc3.yyyy
			0x03,0x00,0x00,0x00, 0x00,0x00,0x0f,0x02, 0x00,0x00,0x00,0xe4,0x02,0x00,0x00,0x00, 0x03,0x00,0x00,0x55,0x01,0x00,0x00,0x00,
			
			//mov oc.xyzw,ft0.xyzw
			0x00,0x00,0x00,0x00, 0x00,0x00,0x0f,0x03, 0x00,0x00,0x00,0xe4,0x02,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
		];
		
		public static const data:Vector.<Number>=new <Number>[
			
			//fc0
			0,//color1_r
			0,//color1_g
			0,//color1_b
			0,//color1_a
			
			//fc1
			0,//color2_r
			0,//color2_g
			0,//color2_b
			0,//color2_a
			
			//fc2
			0,//u_dimension
			0,//v_dimension
			2,
			0,
			
			//fc3
			1,
			0,//alpha
			0,//占位
			0//占位
			
		];
		data.fixed=true;
		
		/**
		 * 
		 * 透明度 （0~1） 默认 1
		 * 
		 */
		public var alpha:Number;
		
		/**
		 * 
		 * 格子大小 （1~100） 默认 10
		 * 
		 */
		public var dimension:Number;
		
		/**
		 * 
		 * 颜色1 默认 null
		 * 
		 */
		public var color1:Pixel4;
		
		/**
		 * 
		 * 颜色2 默认 null
		 * 
		 */
		public var color2:Pixel4;
		

		/**
		 * 
		 * 透明度 （0~1） 默认 1<br/>
		 * 格子大小 （1~100） 默认 10<br/>
		 * 颜色1 默认 null<br/>
		 * 颜色2 默认 null<br/>
		 * 
		 */
		public function Chessboard(_alpha:Number=1,_dimension:Number=10,_color1:Pixel4=null,_color2:Pixel4=null){
			alpha=_alpha;
			dimension=_dimension;
			color1=_color1;
			color2=_color2;
		}
		
		override public function updateParams():void{
			
			//fc0
			data[0]=color1.r;//0 color1_r
			data[1]=color1.g;//0 color1_g
			data[2]=color1.b;//0 color1_b
			data[3]=color1.a;//0 color1_a
			
			//fc1
			data[4]=color2.r;//0 color2_r
			data[5]=color2.g;//0 color2_g
			data[6]=color2.b;//0 color2_b
			data[7]=color2.a;//0 color2_a
			
			//fc2
			data[8]=dimension/uploadBmd.width;//0 u_dimension
			data[9]=dimension/uploadBmd.height;//0 v_dimension
			//2
			//0
			
			//fc3
			//1
			data[13]=alpha
			//0 占位
			//0 占位
		}
		

	}
}